{extend name="layout:base" /}{block name="content"}

<?php
$global=isSupperManagerForSession();
 ?>
<link rel="stylesheet" type="text/css"
	href="/static/My97DatePicker/skin/WdatePicker.css" />
<script charset="utf-8" src="/static/My97DatePicker/WdatePicker.js"></script>
<style type="text/css">
.yg_inp>input {
	margin-bottom: 10px;
}

#zc_detail table {
	margin: 10px;
}

#zc_detail table tr td {
	border: 1px solid #ddd;
	height: 40px;
	line-height: 40px;
	padding-left: 5px;
	padding-right: 5px;
}

.ordertable input {
	width: 90%;
}

.policeLable {
	padding: 2px 4px;
	margin-left: 4px;
}

#taskDate .taskDateItem {
	width: 100%;
	height: 40px;
	line-height: 40px;
	margin: 4px 0px;
}

#taskDate .taskDateItem .taskDateItemLeft {
	width: 10%;
	float: left;
}

#taskDate .taskDateItem .taskDateItemRight1 {
	width: 70%;
	float: left;
	border: 1px solid #139667;
	height: 42px;
}

#taskDate .taskDateItem .taskDateItemRight2 {
	width: 20%;
	float: right;
}

#taskDate .taskDateItem .opUsers img {
	width: 22px;
	margin-left: 5px;
}

#taskDate .taskDateItem .itemUser {
	padding: 4px 6px;
	background: #139667;
	margin-left: 4px;
	color: white;
}

#taskDate .taskDateItem .clear {
	clear: both;
	width: 0px;
	height: 0px;
	overflow: hidden;
}

#taskDate .taskDateItem .jia, #taskDate .taskDateItem .jian {
	font-size: 30px;
	cursor: pointer;
	font-weight: 800;
	margin-left: 5px;
}

.qitem {
	width: 100%;
	height: 30px;
	line-height: 30px;
	text-align: left;
}

.qitem label {
	width: 30px;
	display: inline-block;
	text-align: center;
}

.item_select span {
	display: block;
	height: 20px;
	line-height: 20px;
	overflow: hidden;
	width: 100%;
	text-align: left;
}
</style>

<!--引入JS-->
<script type="text/javascript"
	src="/static/admin/js/ajaxfileupload.js?t=1"></script>



<section class="topBanners">
	<div class="icon"></div>
	<div class="topBannersNav">
		<span data-url="/admin/paper/lists"
			onclick="ContentLoadGo('/admin/rentdevice/lists')">设备管理</span> >
		<span data-url="/admin/rentdevice/daoru"
			onclick="ContentLoadGo('/admin/rentdevice/daoru')">导入</span>

	</div>
</section>
<section id="zc_detail">



	<table class="ordertable" border="0" style="width: 90%;"
		cellspacing="0" cellpadding="0">


		<tr>
			<td style="width: 80px;"><div align="right">产品</div></td>
			<td colspan="7">
				<select name="product_id" id="product_id">
				<?php
        		foreach($tyList as $key=>$val)
				{
				?>
				<option value="<?php echo $val['id']; ?>"  ><?php echo $val['name']; ?></option>
				<?php
        		}
        ?>
				</select>
			</td>
		</tr>

		<tr>
			<td style="width: 80px;"><div align="right">Excel文件</div></td>
			<td colspan="7">
				<form id="jvForm" name="jvForm" action="/api/face/updateImage1"
					method="post" enctype="multipart/form-data">
					<input type="hidden" name="e-mpic" id="e-mpic" value="" /> <a
						style="position: relative; display: block; width: 100px; height: 30px; background: #EEE; border: 1px solid #999; text-align: center; line-height: 30px;"
						href="javascript:void(0);">上传文件 <input
						style="position: absolute; left: 0; top: 0; width: 100px; height: 30px; z-index: 999; opacity: 0;"
						onchange="uploadPic()" type="file" name="file" id="file" />
					</a>
					<div id="updatemsg"></div>
					<div id="updateimg"></div>

				</form>
			</td>
		</tr>

	</table>


</section>
<section id="zc_list"></section>


<script type="text/javascript">
       var daoruList=[];
       function showExcelCont(lists)
       {
    	    daoruList=lists;
			var html = '<div style="width:98%;margin-left:auto;margin-right: auto;height:30px;line-height: 30px;">导入预览</div>';
			html +='<table class="table" style="margin-top:10px;">\n' +
                '<tr>\n' +
                '<th style="width:100px;">DeviceName</th>\n' +
                '<th style="width:100px;">Nickname</th>\n' +
                '</tr>'
           $.each(lists,function(i,v){
               if(i>0) {

                   html += '<tr>\n' +
                       '<td style="text-align:left;">' + v.DeviceName + '</td>\n' +
                       '<td style="text-align:left;">' + v.Nickname + '</td>\n' +
                       '</tr>'
               }
		   });
           html +='<tr>\
          		<td colspan="7" style="height:50px;text-align:center;">\
          	    <input type="button" power="70000"  style="width:120px;margin-top:4px;margin-bottom:4px;padding:0px;padding:4px 5px;" value="确认导入数据" class="link_btn daorudata"/>\
                  </td>\
            </tr>';
    		$("#zc_list").html(html);
       }

       function uploadPic()
       {
    	    $("#updatemsg").html("<font style='color:red;'>文件上传中，请稍后</font>");
    		 $.ajaxFileUpload(
    		   {
	    		   	url: '/api/face/uploadImage1', //用于文件上传的服务器端请求地址
	    		   	secureuri: false, //是否需要安全协议，一般设置为false
	    		   	fileElementId: 'file', //文件上传域的ID
	    		   	dataType: 'text/plain', //返回值类型 一般设置为json
	    		   	success: function (data, status) //服务器成功响应处理函数
	    		   	{
	    		   
	    		   	 if(data.err==0)
	                   {
	                	   var img='<a href="'+data.data.pic+'" target="_blank">'+data.data.pic+'</a>';
	                       $("#updateimg").html(img);
	                       $("#e-mpic").val(data.data.pic);
	                       var url="/admin/rentdevice/parseexcel";
	                       var param={file:data.data.pic};
	                       $("#updatemsg").html("<font style='color:green;'>文件上传成功，正在解析excel，请稍后</font>");
	                       AjaxRequest(url,param,function(data){
	              			   if(data.err==0)
	              			   {
	              				 $("#updatemsg").html("<font style='color:green;'>文件上传成功，解析成功</font>");
	              				 showExcelCont(data.data);
	              			   }
	              			   else
	              			   {
	              				 $("#updatemsg").html("<font style='color:red;'>文件上传成功，解析失败，请重新上传</font>");
	              			   }
	              		   	});
	                   }
	    		   },
	    		   error: function (data, status, e)//服务器响应失败处理函数
	    		   {
	    			   $("#updatemsg").html("<font style='color:red;'>上传失败</font>");
	    		   }
    		   }
    		 )
    		   return false;
    		   
       }
           $(function(){
        	   var gnum=0;
        	   var lastObj;

          	  $(document).on("click",".daorudata",function(){

           	      var that =this;
            	  var url="/admin/rentdevice/daoru";
            	  var lists=JSON.stringify(daoruList);
            	  var pid = $("#product_id").val();
            	  var param={
            			  lists:lists,
					       pid:pid,
                          sys_opt:'daoru'
            	  };

     			 AjaxRequest(url,param,function(data){
       			   if(data.err==0)
       			   {
       				   SuccessTiShi("操作成功");
       					ContentLoadGo("/admin/rentdevice/lists");
       			   }
       			   else
       			   {
       				   ErrTiShi(data.msg);
       			   }
       		   	});
             });
        
        	   
        	  
  		
  				$("#all").click(function(){   
			    	if(this.checked){   
			        	$(".checkBoxInput").attr("checked", true);  
			        	$(".checkBoxInput").prop("checked", true);  
			    	}else{   
						$(".checkBoxInput").attr("checked", false);
						$(".checkBoxInput").prop("checked", false);
			    	}   
			    	var se=getAllSelectItem();
			    	//console.log(se);
			 	}); 
  				 //导航
         	   $(".topBannerItem").click(function(){
         		   
         		   var attArr = $(this).attr();
             	   goToSelfLink(attArr);
             	   
         			
         	   });
  			   
           });
           
	  </script>

{/block}
